#include <iostream>

using std::cout;
using std::endl;

class Point
{
public:
    Point(int ix = 0, int iy = 0)
    : _ix(ix)
    , _iy(iy)
    {
        cout << "Point(int = 0, int = 0)" << endl;
    }

    //this
    void print() const
    {
        if(this != nullptr)
        {
            cout << "(" << this->_ix
                 << ", " << _iy
                 << ")" << endl;
        }
        else
        {
            cout << "this == nullptr" << endl;
        }
    }

    ~Point()
    {
        cout << "~Point()" << endl;
    }

private:
    int _ix;
    int _iy;
};

void test()
{
    int arr[5];
    /* int arr[5] = {1, 3, 5, 7, 9}; */

    Point pt(10, 20);
    Point pt2(30, 40);

    cout << endl << "---------" << endl;
    /* Point pArr[5];//创建5个空对象，走五次构造函数 */
    Point pArr[5] = {Point(1, 2), Point(3, 4), pt, pt2};
    pArr[0].print();
    pArr[1].print();
    pArr[2].print();
    pArr[3].print();
    pArr[4].print();
}

void test2()
{
    /* Point pArr[5] = {Point(1, 2), Point(3, 4)}; */
    /* Point pArr[5] = {{1, 2}, {3, 4}};//ok */
    //逗号表达式,最后一个逗号后面的结果，就是表达式的结果
    int a = (3, 4, 5, 8);
    cout <<"a = " << a << endl;//a = 8
    Point pArr[5] = {(1, 2), (3, 4)};
    pArr[0].print();//(1, 2)???,这个结果是多少(2, 0)
    pArr[1].print();//(3, 4)???,这个结果是多少(4, 0)
    pArr[2].print();
    pArr[3].print();
    pArr[4].print();

}


int main(int argc, char *argv[])
{
    test2();
    return 0;
}

